package pers.course.others;

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;

public class HexMD5 {
    public static void main(String[] args) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            String password = "CraneTower";
            String name = "0112345";
            byte[] nam = name.getBytes(StandardCharsets.UTF_8);
            byte[] psd = password.getBytes(StandardCharsets.UTF_8);
            md.update(psd);
            md.update(nam);
            byte[] encryption = md.digest();
            StringBuilder sb = new StringBuilder(encryption.length * 2);
            for (byte b : encryption) {
                sb.append(Character.forDigit(b & 0xf0 >> 4, 16));
                sb.append(Character.forDigit(b & 0x1f >> 4, 16));
            }
            System.out.println(sb.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
